[codex] Structure preview asset URL failures#3399
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
ApprovabilityVerdict: Approved This PR refactors error handling for browser preview asset URLs, converting to Schema-based error classes with structured context fields while ensuring sensitive data isn't leaked. The changes are limited to error infrastructure with comprehensive test coverage. You can customize Macroscope's approvability policy. Learn more. |
6989347 to
199dc14
Compare
Dismissing prior approval to re-evaluate 199dc14
199dc14 to
c048ffe
Compare
Dismissing prior approval to re-evaluate c048ffe
e27816d to
118514f
Compare
c048ffe to
215b085
Compare
118514f to
c3688f1
Compare
215b085 to
8751fdb
Compare
c3688f1 to
ca92705
Compare
8751fdb to
087f4d1
Compare
ca92705 to
f689d14
Compare
087f4d1 to
8c4c9b9
Compare
f689d14 to
5a8a7d1
Compare
8c4c9b9 to
e2f90b8
Compare
5a8a7d1 to
7367e8a
Compare
e2f90b8 to
0de1a6f
Compare
7367e8a to
01b1b93
Compare
8184293 to
6604762
Compare
Dismissing prior approval to re-evaluate 6604762
6604762 to
83d49a1
Compare
01b1b93 to
9214cdf
Compare
83d49a1 to
5dc67af
Compare
9214cdf to
23b0b8e
Compare
5dc67af to
b6ec6cf
Compare
23b0b8e to
f3b05ea
Compare
b6ec6cf to
9952de4
Compare
f3b05ea to
1a24dcc
Compare
6c4608c to
f1b1d68
Compare
e6a4567 to
7ef6bc2
Compare
f1b1d68 to
6e21cc7
Compare
7ef6bc2 to
b74fe0b
Compare
6e21cc7 to
2d0461b
Compare
Co-authored-by: codex <codex@users.noreply.github.com>
b74fe0b to
1824661
Compare
2d0461b to
56e0750
Compare
Summary
BrowserPreviewAssetUrlInvalidErrorScope
apps/web/src/browser/openFileInPreview.tsand its focused testChatMarkdownreporting are intentionally deferred until [codex] Preview workspace image files #3259 and [codex] Report markdown interaction failures #3355 are integratedStack dependency
codex/stack-pr-3259mirrors the exact fork head of draft [codex] Preview workspace image files #3259 because GitHub cannot directly target a fork branch as this PR basemainand retarget the PR tomainValidation
pnpm vp test apps/web/src/browser/openFileInPreview.test.tspnpm vp checkpnpm vp run typecheckNote
Medium Risk
Changes integrated-browser open paths and error typing in chat markdown; invalid asset URLs now fail recoverably instead of dying, with safer diagnostics around signed URLs.
Overview
Preview asset URL construction in
openFileInPreviewno longer usesresolveAssetUrlorCause.diewhen the base/relative URL pair is invalid. It builds the URL withnew URL(relative, base)and returnsBrowserPreviewAssetUrlInvalidErrorviaCause.fail, carrying environment/thread/file context, URL lengths and expiry, and the original parser cause—without storing raw base or signed relative URLs.Browser preview errors are refactored to Effect
Schema.TaggedErrorClasstypes with fixed user-facing messages:BrowserPreviewUnavailableError(runtime unsupported), plus newBrowserPreviewThreadContextUnavailableErrorandBrowserPreviewEnvironmentDisconnectedError.ChatMarkdownreturns these specific failures when opening links or workspace files in the integrated browser instead of overloadingBrowserPreviewUnavailableErrorwith ad hoc messages.Tests in
openFileInPreview.test.tscover the fixed unavailable message, invalid-asset-URL diagnostics, cause identity, and that serialized errors do not leak signed tokens.Reviewed by Cursor Bugbot for commit 56e0750. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Structure browser preview asset URL failures as typed errors in
openFileInPreviewSchema.TaggedErrorClasserrors for three new failure cases: missing thread context (BrowserPreviewThreadContextUnavailableError), disconnected environment (BrowserPreviewEnvironmentDisconnectedError), and invalid asset URL (BrowserPreviewAssetUrlInvalidError).BrowserPreviewAssetUrlInvalidErrorcaptures safe diagnostic fields (environmentId,threadId,filePath,httpBaseUrlLength,relativeUrlLength,expiresAt) and preserves the original cause, avoiding exposure of sensitive URL contents.resolveAssetUrlwith anew URL(relativeUrl, httpBaseUrl)call wrapped in try/catch; failures are surfaced asBrowserPreviewAssetUrlInvalidErrorinstead of a defect die.isBrowserPreviewAssetUrlInvalidErroras a type guard viaSchema.is.openFileInPreviewnow receive typed failures for URL construction errors instead of unhandled defects.Macroscope summarized 56e0750.